﻿<%@ Page Title="" Language="C#" MasterPageFile="~/AdminPanel/AdminSite.Master" AutoEventWireup="true" CodeBehind="StartBooking.aspx.cs" Inherits="FastTrackCabService.AdminPanel.StartBooking" %>
<%@ Import Namespace="BusinessLogicLayer" %>
<%@ Import Namespace="BusinessObjects" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Style/FullView.css" rel="stylesheet" type="text/css"/>
    <style>
        .detailsView table:last-child th { padding: 0.5em; }

        .detailsView table:last-child td { width: auto; }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:DetailsView ID="dvPickAndDrop" Visible="False" CssClass="detailsView" runat="server"
                 AutoGenerateRows="False" CellPadding="4" ForeColor="#333333" GridLines="None"
                 HeaderText="Booking details">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
    <EditRowStyle BackColor="#999999"/>
    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
    <Fields>
        <asp:BoundField DataField="BookingId" HeaderText="Booking Id" SortExpression="BookingId"/>
        <asp:TemplateField HeaderText="Customer" SortExpression="CustomerId">
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# "<a href=\"CustomerFullView.aspx?cusId=" + Eval("CustomerId") + "\">" + CustomerBLL.GetCustomerName(Convert.ToInt32(Eval("CustomerId"))) + "</a>" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="BookedDateTime" HeaderText="Booked date &amp; time" SortExpression="BookedDateTime"/>
        <asp:BoundField DataField="OriginDateTime" HeaderText="Pickup date &amp; time" SortExpression="OriginDateTime"/>
        <asp:TemplateField HeaderText="From">
            <ItemTemplate>
                <asp:DetailsView ID="DetailsView2" Style="width: 100%;" CssClass="innerDetailsView"
                                 runat="server" CellPadding="4" DataSource='<%# new List<CurrentLocation> {(CurrentLocation) Eval("OriginLocation")} %>'
                                 ForeColor="#333333" GridLines="None" Height="50px" Width="125px" AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
                    <EditRowStyle BackColor="#999999"/>
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
                    <Fields>
                        <asp:BoundField DataField="HomeNumberOrName" HeaderText="No / Name"/>
                        <asp:BoundField DataField="Street" HeaderText="Street"/>
                        <asp:BoundField DataField="City" HeaderText="City"/>
                        <asp:TemplateField HeaderText="District">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# DistrictBLL.GetDistrict(Convert.ToByte(Eval("DistrictId"))) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                </asp:DetailsView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="MidPoint" HeaderText="To" SortExpression="MidPoint"/>
        <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type"/>
        <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status"/>
        <asp:TemplateField HeaderText="Supervisor">
            <ItemTemplate>
                <%# "<a href='SupervisorFullView.aspx?staffId=" + Eval("SupervisorId") + "'>" + StaffBLL.GetStaffById(Convert.ToInt32(Eval("SupervisorId"))).FirstName + "</a>" %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="ApproximateEndDateTime" HeaderText="Approximate end date & time" SortExpression="ApproximateEndDateTime"/>
        <asp:TemplateField HeaderText="Vehicle(s)">
            <ItemTemplate>
                <asp:GridView ID="GridView1" runat="server" DataSource='<%# Eval("VehicleDrivers") %>'
                              AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <Columns>
                        <asp:TemplateField HeaderText="Vehicle">
                            <ItemTemplate>
                                <%# "<a href='VehicleFullView.aspx?regNo=" + Eval("VehicleRegistrationNo") + "'>" + Eval("VehicleRegistrationNo") + "</a>" %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Type">
                            <ItemTemplate>
                                <%# VehicleBLL.GetVehiclesByRegNo(Eval("VehicleRegistrationNo").ToString()).Type %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Driver">
                            <ItemTemplate>
                                <%# "<a href='DriverFullView.aspx?staffId=" + Eval("DriverId") + "'>" + StaffBLL.GetStaffById(Convert.ToInt32(Eval("DriverId"))).FirstName + "</a>" %>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#999999"/>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
                    <SortedAscendingCellStyle BackColor="#E9E7E2"/>
                    <SortedAscendingHeaderStyle BackColor="#506C8C"/>
                    <SortedDescendingCellStyle BackColor="#FFFDF8"/>
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
                </asp:GridView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <ItemStyle BackColor="#E2DED6"/>
            <ItemTemplate>
                <div style="text-align: center;">
                    <asp:ImageButton ID="ibReject" Style="outline: none;"
                                     OnClick="ibReject_OnClick" OnClientClick=" if (!confirm('Are you sure do you want to reject this booking?')) return false; "
                                     ToolTip="Reject this booking" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/reject_x.png" runat="server"/>
                    <asp:ImageButton ID="ibReConfirm" Style="margin-left: 1em; outline: none; width: 40px;" OnClick="ibReConfirm_OnClick" OnClientClick=" if (!confirm('Are you sure do you want to re-confirm this booking by reassigning new details?\nWarning: This will role back to pending stage!')) return false; "
                                     ToolTip="Re-assign / re-confirm with new details" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/edit-notes.png" runat="server"/>
                    <asp:ImageButton ID="ibStart" Style="margin-left: 1em; outline: none; width: 40px;"
                                     OnClick="ibStart_OnClick"
                                     ToolTip="Execute this booking" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/Start-icon.png" runat="server"/>
                </div>

            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
</asp:DetailsView>
<asp:DetailsView ID="dvPick" Visible="False" CssClass="detailsView" runat="server"
                 AutoGenerateRows="False" CellPadding="4" ForeColor="#333333" GridLines="None"
                 HeaderText="Booking details">
    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
    <EditRowStyle BackColor="#999999"/>
    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
    <Fields>
        <asp:BoundField DataField="BookingId" HeaderText="Booking Id" SortExpression="BookingId"/>
        <asp:TemplateField HeaderText="Customer" SortExpression="CustomerId">
            <ItemTemplate>
                <asp:Label ID="Label2" runat="server" Text='<%# "<a href=\"CustomerFullView.aspx?cusId=" + Eval("CustomerId") + "\">" + CustomerBLL.GetCustomerName(Convert.ToInt32(Eval("CustomerId"))) + "</a>" %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="BookedDateTime" HeaderText="Booked date &amp; time" SortExpression="BookedDateTime"/>
        <asp:BoundField DataField="OriginDateTime" HeaderText="Pickup date &amp; time" SortExpression="OriginDateTime"/>
        <asp:TemplateField HeaderText="From">
            <ItemTemplate>
                <asp:DetailsView ID="DetailsView2" Style="width: 100%;" CssClass="innerDetailsView"
                                 runat="server" CellPadding="4" DataSource='<%# new List<CurrentLocation> {(CurrentLocation) Eval("OriginLocation")} %>'
                                 ForeColor="#333333" GridLines="None" Height="50px" Width="125px" AutoGenerateRows="False">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True"/>
                    <EditRowStyle BackColor="#999999"/>
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True"/>
                    <Fields>
                        <asp:BoundField DataField="HomeNumberOrName" HeaderText="No / Name"/>
                        <asp:BoundField DataField="Street" HeaderText="Street"/>
                        <asp:BoundField DataField="City" HeaderText="City"/>
                        <asp:TemplateField HeaderText="District">
                            <ItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# DistrictBLL.GetDistrict(Convert.ToByte(Eval("DistrictId"))) %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                </asp:DetailsView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="Destination" HeaderText="To" SortExpression="Destination"/>
        <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type"/>
        <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status"/>
        <asp:TemplateField HeaderText="Supervisor">
            <ItemTemplate>
                <%# "<a href='SupervisorFullView.aspx?staffId=" + Eval("SupervisorId") + "'>" + StaffBLL.GetStaffById(Convert.ToInt32(Eval("SupervisorId"))).FirstName + "</a>" %>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="ApproximateEndDateTime" HeaderText="Approximate end date & time" SortExpression="ApproximateEndDateTime"/>
        <asp:TemplateField HeaderText="Vehicle(s)">
            <ItemTemplate>
                <asp:GridView ID="GridView1" runat="server" DataSource='<%# Eval("VehicleDrivers") %>'
                              AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775"/>
                    <Columns>
                        <asp:TemplateField HeaderText="Vehicle">
                            <ItemTemplate>
                                <%# "<a href='VehicleFullView.aspx?regNo=" + Eval("VehicleRegistrationNo") + "'>" + Eval("VehicleRegistrationNo") + "</a>" %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Type">
                            <ItemTemplate>
                                <%# VehicleBLL.GetVehiclesByRegNo(Eval("VehicleRegistrationNo").ToString()).Type %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Driver">
                            <ItemTemplate>
                                <%# "<a href='DriverFullView.aspx?staffId=" + Eval("DriverId") + "'>" + StaffBLL.GetStaffById(Convert.ToInt32(Eval("DriverId"))).FirstName + "</a>" %>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#999999"/>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>
                    <SortedAscendingCellStyle BackColor="#E9E7E2"/>
                    <SortedAscendingHeaderStyle BackColor="#506C8C"/>
                    <SortedDescendingCellStyle BackColor="#FFFDF8"/>
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE"/>
                </asp:GridView>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField ShowHeader="False">
            <ItemStyle BackColor="#E2DED6"/>
            <ItemTemplate>
                <div style="text-align: center;">
                    <asp:ImageButton ID="ibReject" Style="outline: none;"
                                     OnClick="ibReject_OnClick" OnClientClick=" if (!confirm('Are you sure do you want to reject this booking?')) return false; "
                                     ToolTip="Reject this booking" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/reject_x.png" runat="server"/>
                    <asp:ImageButton ID="ibReConfirm" OnClick="ibReConfirm_OnClick" Style="margin-left: 1em; outline: none; width: 40px;" OnClientClick=" if (!confirm('Are you sure do you want to re-confirm this booking by reassigning new details?\nWarning: This will role back to pending stage!')) return false; "
                                     ToolTip="Re-assign / re-confirm with new details" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/edit-notes.png" runat="server"/>
                    <asp:ImageButton ID="ibStart" Style="margin-left: 1em; outline: none; width: 40px;"
                                     OnClick="ibStart_OnClick"
                                     ToolTip="Execute this booking" PostBackUrl='<%# "?bookingId=" + Eval("BookingId") %>'
                                     ImageUrl="~/Images/Start-icon.png" runat="server"/>
                </div>
            </ItemTemplate>
        </asp:TemplateField>
    </Fields>
    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"/>
    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center"/>
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>
</asp:DetailsView>
</asp:Content>